#! /bin/sh
fcincludes=/usr/include/fontconfig
fclib=/usr/lib/libfontconfig.so
cat <<EOT >fc.tmp
|
| HelFORTH interface to libfontconfig
|
context FontConfig
{~ FontConfig
lazylink libfontconfig.so
EOT
for a in `(cd $fcincludes ; ls *.h )` ; do
  ./fugen fontconfig/$a -- -I$fcincludes `pkg-config --cflags freetype2` >>fc.tmp
done
echo lazy off >>fc.tmp
echo ~} >>fc.tmp
bong $fclib <fc.tmp | perl >fontconfig.interface -e '
#
# cleanups
#
  my $last = "";
  while (<>) {
  	my ($w, $x, $y);
  	while (/^\|\n/) {
  		$w = $_;
  		$x = <>;
  		$y = <>;
  		$_ = <>;
  		if (/^((\|)|(lazy))/) {
  			$w = $x = $y = "";
  		}
  	}
	/^lazy/ and $last = "";
  	print $last, $w, $x, $y;
  	if (/^lazy/) {
  		$last = "\n\n$_";
  	} else {
  		print $_;
  		$last = "";
  	}
  }
  print $last; # lazy off
'
rm -f fc.tmp
